package com.digoyo.hr.service;

import com.digoyo.hr.mapper.RoleMapper;
import com.digoyo.hr.model.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: Daniel
 * @Description:
 * @Date: Created in 12:28 PM 2020/6/18
 * @Modified By:
 */

@Service
public class RoleService {
    @Autowired
    RoleMapper roleMapper;
    public List<Role> getAllRoles() {
        return roleMapper.getAllRoles();
    }

    public Integer addRole(Role role) {
        if (!role.getName().startsWith("ROLE_")) {
            role.setName("ROLE_"+role.getName());
        }
        return roleMapper.insert(role);
    }
}
